package fr.louloutes.lolshooter.engine.objects.protagonists;

import android.graphics.Rect;
import fr.louloutes.lolshooter.engine.objects.weapons.SimpleMonsterGun;
import fr.louloutes.lolshooter.engine.sprites.LolSprite;

/**
 * Class Mosnter: monster handling
 * 
 * @author Louloute
 * 
 */
public class Monster extends Protagonist
{

	public static final int margins = 10;

	int value = 25;
	double speed = 0.1;
	int direction = 1;

	/**
	 * Constructor with initializations
	 * 
	 * @param sprite
	 * @param startsGoingLeft
	 */
	public Monster( LolSprite sprite, boolean startsGoingLeft )
	{
		super( 50, sprite, new SimpleMonsterGun() );
		if ( startsGoingLeft )
		{
			direction = -1;
		}
	}

	/**
	 * Update monster position
	 * 
	 * @param elapsedTime
	 * @param frameRect
	 */
	@Override
	public void move( long elapsedTime, Rect frameRect )
	{
		double movement = elapsedTime * speed;
		if ( getSprite().rect.right + direction * movement > frameRect.right
				- margins )
		{
			direction = -1;
		}
		if ( getSprite().rect.left + direction * movement < frameRect.left
				+ margins )
		{
			direction = +1;
		}

		setPosition( getX() + movement * direction, getY() );
	}

	public int getValue()
	{
		return value;
	}

	public void setValue( int value )
	{
		this.value = value;
	}

	public double getSpeed()
	{
		return speed;
	}

	public void setSpeed( double speed )
	{
		this.speed = speed;
	}

	public int getDirection()
	{
		return direction;
	}

	public void setDirection( int direction )
	{
		this.direction = direction;
	}

}
